-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
65 lines (47 loc) · 1.05 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <iostream>
using namespace std;
double obterMaior(double s[], int tam);
double obterMenor(double s[], int tam);
int main(){
const int tam = 7;
int n, i;
string str;
double gd, saltos[tam], menor, maior, res;
cin >> n;
while(n--){
cin >> str;
cin >> gd;
for(i = 0; i < tam; i++){
cin >> saltos[i];
res += saltos[i];
}
maior = obterMaior(saltos, tam);
menor = obterMenor(saltos, tam);
res = (res - (maior + menor)) * gd;
cout << fixed;
cout.precision(2);
cout << str << " " << res << endl;
res = 0;
}
return 0;
}
double obterMaior(double s[], int tam){
int i;
double maior;
maior = s[0];
for(i = 0; i < tam; i++){
if(maior < s[i])
maior = s[i];
}
return maior;
}
double obterMenor(double s[], int tam){
int i;
double menor;
menor = s[0];
for(i = 0; i < tam; i++){
if(menor > s[i])
menor = s[i];
}
return menor;
}